<!--
 * @Author: 搁浅小时光 mork_wu@163.com
 * @Date: 2022-06-30 14:48:51
 * @LastEditors: 搁浅小时光 mork_wu@163.com
 * @LastEditTime: 2022-07-25 15:50:54
 * @FilePath: \limsVite\src\views\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div >
        <div class="" @click="addx">2321323</div>
        {{counter.x}}
    </div>
</template>

<script setup lang="ts"> 
  import { useCounterStore } from '../store'
  import {storeToRefs} from "pinia" 
   const counter = useCounterStore()  
    /* 通过$patch直接修改store状态，$patch方法接收一个函数，函数的参数是该模块的状态
    在这个函数中我们可以直接修改store状态 */
    const addx=()=>{counter.$patch((s)=>{s.x++})}

   const {x,y} =  storeToRefs(counter)
</script>

<style lang="scss" scoped>

</style>